home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BMUG Revelations
/
BMUG Revelations.toast
/
Programming
/
Programming Languages
/
Yerk 3.64
/
Supplement
/
Unsupported
/
Utilities
/
sortFile
< prev
next >
Wrap
Text File
|
1986-10-19
|
755b
|
35 lines
\ sort an ascii file
\ 10/19/86 cdn Version 1.0
500 Ordered-Col lines
\ ( addr1 addr2 -- result )
: compStr
swap count rot count $=
;
: sortFile
new: loadFile
txType 1 stdget: topFile 0= IF exit THEN
open: topFile abort" Can't open file"
CR ." Reading file…"
BEGIN
buf255 255 readLine: topFile 0=
WHILE
bytesRead: topFile 1+ newPtr -dup 0= abort" Ran out of memory!"
dup add: lines
buf255 bytesRead: topFile rot >str255 drop
REPEAT
close: topFile drop
CR ." Sorting" size: lines . ." lines…"
ixAddr: lines size: lines 'c compStr sort
CR ." Writing file…"
open: topFile abort" Can't reopen file"
size: lines 0
DO i at: lines dup count write: topFile abort" Write failed!"
killPtr
LOOP
close: topFile drop
remove: loadFile
;